
var express = require('express');
var router = express.Router();
var sqlQuery = require('../../../module/sql');

/* GET users listing. */
//轮播图
router.get('/',async(req,res)=>{
    res.render('admin/slide/slidelist')
})



router.get('/api',async(req,res)=>{
    let page = parseInt(req.query.page);  //第几页
    let limitNum = parseInt(req.query.limit); //限制多少条
    let sqlStr = 'select * from slide LIMIT ?,?'
    let arr = [(page-1)*limitNum,limitNum]
    let result = await sqlQuery(sqlStr,arr);
    //获取电影的总数
    let sqlStr1 = "select count(id) as number from slide"
    let result1 = await sqlQuery(sqlStr1)
    let count = result1[0].number
    let options ={
      "code": 0,
      "msg": "",
      "count": count,
      "data": Array.from(result)
    }
    res.json(options)
    console.log(options)
  })
  



module.exports = router;
